<template>
  <div>
    <!--菜单-->
    <MenuComponent  :onEvent="clickMenu" :selectCodeEvent="selectCodeHandle"/>

    <!--主页-->
      <div class="main-container">
        <component :is="currentPage"/>
      </div>
  </div>
</template>


<script >
import MenuComponent from "./components/base/MenuComponent.vue";
import KLinePage from "./components/KLinePage.vue";
import TimeChartPage from "./components/TimeChartPage.vue";
import StockPredectPage from "./components/StockPredectPage.vue";

export default {
  components: { 
    MenuComponent, 
    KLinePage,
    TimeChartPage,
    StockPredectPage
  },
  data() {
    return {
      data:1,
      currentPage: "KLinePage"
    }
  },
  methods: {
      clickMenu(value) {
          console.log("接收数据" + value)
          if (this.data !== value) {
            this.data = value
            if (this.data == 1) {
              this.currentPage = 'KLinePage'
            } else if (this.data == 2){
              this.currentPage = 'TimeChartPage'
            } else if (this.data == 3){
              this.currentPage = 'StockPredectPage'
            } {

            }
            
          }
      },
      selectCodeHandle(value) {
        
        const stockCode = value.split(' ')[0]
        const stockName = value.split(' ')[1]
        console.log("接收数据" +  stockCode + stockName)
        this.$store.dispatch('changeStockCode', stockCode);
        this.$store.dispatch('changeStockName', stockName);
      },
  }
};
</script>

<style scoped>

</style>